package com.freesky.biz.icbc.controller;

import com.freesky.biz.icbc.domain.*;
import com.freesky.biz.icbc.service.IFinanceRecordService;
import com.freesky.common.annotation.Log;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 晋级有礼
 */
@RestController
@RequestMapping("/icbc/finance/record")
public class FinanceRecordController extends BaseController {

    @Autowired
    private IFinanceRecordService financeRecordService;


    @PreAuthorize("@ss.hasPermi('icbc:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFinanceRecord financeRecord) {
        startPage();
        List<TFinanceRecord> list = financeRecordService.findList(financeRecord);
        return getDataTable(list);
    }

    @Log(title = "晋级有礼", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:record:export')")
    @GetMapping("/export")
    public AjaxResult export(TFinanceRecord financeRecord,
                             HttpServletResponse response) {
        return financeRecordService.exportFile(financeRecord);
    }

    @PreAuthorize("@ss.hasPermi('icbc:record:list')")
    @GetMapping("/listEnroll")
    public TableDataInfo listEnroll(TFinanceEnrollRecord enrollRecord) {
        startPage();
        List<TFinanceEnrollRecord> list = financeRecordService.findEnrollList(enrollRecord);
        return getDataTable(list);
    }

    @Log(title = "工行推荐礼", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:record:export')")
    @GetMapping("/exportEnroll")
    public AjaxResult exportEnroll(TFinanceEnrollRecord enrollRecord,
                             HttpServletResponse response) {
        return financeRecordService.exportEnrollFile(enrollRecord);
    }


}
